import {requestDetailData} from '@/api/detailApi'

const state = {
  detailInfo:{}
}
const mutations = {
  SET_DETAIL_STATE(state,value){
    state.detailInfo = value
  }
}
const actions = {
  getDetail : async ({commit},skuId) => {
    const re = await requestDetailData(skuId)
    commit('SET_DETAIL_STATE',re)
  }
}
const getters ={
  categoryView(state){
    return state.detailInfo.categoryView || {}
  },
  skuInfo(state){
    return state.detailInfo.skuInfo || {}
  },
  spuSaleAttrList(state){
    return state.detailInfo.spuSaleAttrList || []
  }
}
export default {
  namespaced:true,
  state,
  mutations,
  actions,
  getters
}
